#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define str string
#define all(x) (x).begin(),(x).end()
#define ms(a,t) memset(a,t,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define db double
const int maxn = 5e4+10;
const int maxm = 1e3+10;
const int mod = 998244353;
const ll INF = 0x3f3f3f3f;
const db eps = 1e-7;
int n,m;
char s[maxn],t[maxm];
int nxt[maxm],to[maxm][26];
int f[maxn][maxm];
void Solve() {
	cin >> (s+1) >> (t+1); n = strlen(s+1); m = strlen(t+1);
//	cerr<<n<<' '<<m<<'\n';
	nxt[1] = 0;
	for(int i = 2; i <= m; i++) {
		nxt[i] = nxt[i-1];
		while(nxt[i] != 0 && t[nxt[i]+1] != t[i]) {
			nxt[i] = nxt[nxt[i]];
		}
		if(t[nxt[i]+1] == t[i]) nxt[i]++;
	}
	to[0][t[1]-'a'] = 1;
	for(int i = 1; i < m; i++) {
		for(int j = 0; j < 26; j++) {
			to[i][j] = to[nxt[i]][j];
		}
		to[i][t[i+1]-'a'] = i+1;
	}
	for(int i = 1; i <= m; i++) f[0][i] = -INF;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < m; j++) {
			f[i][j] = f[i-1][j];
		}
		for(int j = 0; j < m; j++) {
			int k = to[j][s[i]-'a'];
			f[i][k] = max(f[i][k],f[i-1][j]+1);
		}
//		for(int j = 0; j < m; j++) cerr<<to[j][s[i]-'a']<<' ';
//		for(int j = 0; j < m; j++) cerr<<f[i][j]<<' ';
//		cerr<<'\n';
	}
	int ans = *max_element(f[n],f[n]+m);
	cout<<ans<<'\n';
}
int main() {
	freopen("neck.in","r",stdin);
	freopen("neck.out","w",stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	int T; cin >> T; while(T--)
	Solve();
	return 0;
}
